<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>主页</title>
    <link href="${pageContext.request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container" style="width: 600px;">
    <h1>欢迎光临${sessionScope.user.username}</h1>
    <form action="${pageContext.request.contextPath}/logout" method="post">
        <security:csrfInput/>
        <button type="submit" class="btn btn-default">注销登录</button>
    </form>

    <ul class="nav nav-tabs">
        <li role="presentation"><a href="${pageContext.request.contextPath}/Student/goHome">Home</a></li>
        <li role="presentation" class="active"><a href="#">考试系统</a></li>
        <li role="presentation"><a href="${pageContext.request.contextPath}/Student/getTests">查看所有考试</a></li>
    </ul>

    <table class="table">
        <tr>
            <th>编号</th>
            <th>考试描述</th>
            <th>考试成绩</th>
            <th>使用时间</th>
            <th>考试开始时间</th>
            <th>开始作答时间</th>
            <th>查看试卷</th>
        </tr>
        <c:forEach items="${studentExam}" var="grade" varStatus="s">
            <tr>
                <td>${s.count}</td>
                <td>${grade.test.context}</td>
                <td><c:if test="${grade.score!=0}">${grade.score}</c:if></td>
                <td><c:if test="${grade.beginTime!=null}">${grade.useTime}</c:if></td>
                <td>${grade.test.beginDate}</td>
                <td><c:if test="${grade.beginTime!=null}">${grade.beginTime}</c:if></td>
                <td><c:if test="${grade.beginTime!=null}"><a
                        href="${pageContext.request.contextPath}/Student/getExam/${grade.id}">查看</a></c:if>
                    <c:if test="${grade.beginTime==null}"><a
                            href="${pageContext.request.contextPath}/Student/beginExam/${grade.id}/${grade.test.examId}">答题</a></c:if>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>
</body>
</html>
